insert overwrite table jms_dm.dm_all_transfer_count_bak_dt partition (dt)
select
     t.dt as date_time
    ,t.taking_code     --揽收网点
    ,t.taking_name
    ,t.taking_agent_code                --'代理区编码',
    ,t.taking_agent_name                --'代理区名称,',
    ,t.taking_provider_id              --'省份ID',
    ,t.taking_provider_desc          --'省份',
    ,t.taking_city_id                    --'城市ID',
    ,t.taking_city_desc                  --'城市',
    ,t.first_center_network_code --始发中心
    ,t.first_center_network_name
    ,sum(t.front_number ) as  front_number  --件量
    ,sum(t.front_plan_zz ) as front_plan_zz  --规划中转次数
    ,sum(t.front_actual_zz) as front_actual_zz --实际中转次数
    ,sum(t.front_agent_in) as front_agent_in --代理区内中转次数
    ,sum(t.front_agent_out) as front_agent_out --代理区外中转次数
    ,sum(t.front_reback) as front_reback --退件件量
    ,sum(t.front_reback_zz ) as front_reback_zz --退件中转次数
    ,sum(t.front_rational) as front_rational --不合理件量
    ,sum(t.front_rational_zz) front_rational_zz --不合理中转次数
    ,sum(t.front_proble) as front_proble  --问题件件量
    ,sum(t.front_proble_zz) as front_proble_zz  --问题件中转次数
    ,sum(t.front_is_wrong) as front_is_wrong  --网点错发件件量
    ,sum(t.front_is_wrong_zz) as front_is_wrong_zz  --网点错发件中转次数
    ,sum(t.front_bak_route) as front_bak_route  --备用路由件量
    ,sum(t.front_bak_route_zz ) as front_bak_route_zz  --备用路由中转次数
    ,t.dt
from jms_dm.dm_all_transfer_count_site_dt t
where   t.dt='{{ execution_date  | cst_ds }}'  
group by
     t.dt
    ,t.taking_code     --揽收网点
    ,t.taking_name
    ,t.taking_agent_code                --'代理区编码',
    ,t.taking_agent_name                --'代理区名称,',
    ,t.taking_provider_id              --'省份ID',
    ,t.taking_provider_desc          --'省份',
    ,t.taking_city_id                    --'城市ID',
    ,t.taking_city_desc                  --'城市',
    ,t.first_center_network_code --始发中心
    ,t.first_center_network_name

 distribute by pmod(hash(rand()), 3)
;